package com.ruoyi.project.wms.status.service.impl;

import java.util.List;

import com.ruoyi.project.wms.customerorder.domain.WmsCustomerOrder;
import com.ruoyi.project.wms.customerorder.mapper.WmsCustomerOrderMapper;
import com.ruoyi.project.wms.space.domain.WmsStroeSpace;
import com.ruoyi.project.wms.space.mapper.WmsStroeSpaceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.wms.status.mapper.WmsCustomerStatusMapper;
import com.ruoyi.project.wms.status.domain.WmsCustomerStatus;
import com.ruoyi.project.wms.status.service.IWmsCustomerStatusService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-31
 */
@Service
public class WmsCustomerStatusServiceImpl implements IWmsCustomerStatusService 
{
    @Autowired
    private WmsCustomerStatusMapper wmsCustomerStatusMapper;
    @Autowired
    private WmsCustomerOrderMapper wmsCustomerOrderMapper;

    @Autowired
    private WmsStroeSpaceMapper wmsStroeSpaceMapper;
    /**
     * 查询【请填写功能名称】
     * 
     * @param oCid 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public WmsCustomerStatus selectWmsCustomerStatusById(Integer oCid)
    {
        return wmsCustomerStatusMapper.selectWmsCustomerStatusById(oCid);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param wmsCustomerStatus 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<WmsCustomerStatus> selectWmsCustomerStatusList(WmsCustomerStatus wmsCustomerStatus)
    {
        return wmsCustomerStatusMapper.selectWmsCustomerStatusList(wmsCustomerStatus);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param wmsCustomerStatus 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertWmsCustomerStatus(WmsCustomerStatus wmsCustomerStatus)
    {
        return wmsCustomerStatusMapper.insertWmsCustomerStatus(wmsCustomerStatus);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param wmsCustomerStatus 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateWmsCustomerStatus(WmsCustomerStatus wmsCustomerStatus)
    {
       int i=wmsCustomerStatusMapper.updateWmsCustomerStatus(wmsCustomerStatus);
        if (i>0){
            int oCid=wmsCustomerStatus.getoCid();
            WmsCustomerOrder wmsCustomerOrder = wmsCustomerOrderMapper.selectWmsCustomerOrderById(oCid);
            Integer dan = wmsCustomerOrder.getCustomerOrderNumber();
            WmsStroeSpace wmsStroeSpace = wmsStroeSpaceMapper.selectWmsStroeSpaceByPId(wmsCustomerOrder.getpId());
            wmsStroeSpace.setStroeSpaceNum(wmsStroeSpace.getStroeSpaceNum()-dan);
            wmsStroeSpaceMapper.updateWmsStroeSpaceByPId(wmsStroeSpace);

        }
        return i;
    }

    @Override
    public int updateWmsCustomerStatus02(Integer oCid) {
        return wmsCustomerStatusMapper.insertWmsCustomerStatus02(oCid);

    }

    /**
     * 删除【请填写功能名称】对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWmsCustomerStatusByIds(String ids)
    {
        return wmsCustomerStatusMapper.deleteWmsCustomerStatusByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param oCid 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteWmsCustomerStatusById(Integer oCid)
    {
        return wmsCustomerStatusMapper.deleteWmsCustomerStatusById(oCid);
    }
}
